import axios from '@/plugins/axios';
const BASE_API = import.meta.env.VITE_APP_BASE_APIURL as string;

import { CommonStore } from '@/store';
import { CommontTypes, ResponseVo, GoodsCategoryTypes } from '@/type';

export namespace GoodsCategoryService {
  export const findAllGoodsCategory = async (): Promise<ResponseVo<GoodsCategoryTypes.GoodsCategoryItem[]>> => {
    let res:ResponseVo<any> = await axios.get('/category/list',{ baseURL: BASE_API});
    return res;
  };

  export const addGoodsCategory = async (data:Partial<GoodsCategoryTypes.GoodsCategoryItem>): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/category/add',data,{baseURL: BASE_API});
    return res;
  };

  export const editGoodsCategory = async (data:Partial<GoodsCategoryTypes.GoodsCategoryItem>): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.post('/category/edit',data,{baseURL: BASE_API});
    return res;
  };

  export const detailGoodsCategory = async (goodsCategoryId:number): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/category/detail',{ params:{goodsCategoryId}, baseURL: BASE_API});
    return res;
  };

  export const deleteGoodsCategory = async (goodsCategoryId:number): Promise<ResponseVo<any>> => {
    let res:ResponseVo<any> = await axios.get('/category/delete',{ params:{goodsCategoryId},baseURL: BASE_API});
    return res;
  };
}
